﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TPMS_ScanComparison.Helper
{
    public class SqlHelper
    {
        //创建数据库对象
        public static SqlSugarClient sqliteDb = new SqlSugarClient(new ConnectionConfig()
        {
            ConnectionString = @"DataSource=SqlSugar4xTest.sqlite",
            DbType = DbType.Sqlite,
            IsAutoCloseConnection = true
        },
        db => {

            db.Aop.OnLogExecuting = (sql, pars) =>
            {

                //获取原生SQL推荐 5.1.4.63  性能OK
                Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));

            };
        });

        // 创建数据库对象
        public static SqlSugarClient PostgreDb = new SqlSugarClient(new ConnectionConfig()
        {
            // PostgreSQL 连接字符串，替换为实际信息
            ConnectionString = "Server=131.10.10.80;Port=5432;Database=jyk_scada;User Id=mes_read_user;Password=mes_scada;",
            // 数据库类型为 PostgreSQL
            DbType = DbType.PostgreSQL,
            // 自动关闭连接
            IsAutoCloseConnection = true,
        },
        db =>
        {
            // SQL 执行日志事件（可选，用于调试查看执行的 SQL）
            db.Aop.OnLogExecuting = (sql, pars) =>
            {
                // 输出原生 SQL 到控制台
                Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));
            };
        });

    }
}
